"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.download = download;
exports.downloadByBlob = downloadByBlob;
exports.splitChunks = splitChunks;
/*
 * @Descripttion: 文件上传下载
 * @Author: gll
 * @Date: 2023-05-18 10:55:30
 * @LastEditors: gll
 * @LastEditTime: 2023-06-13 14:09:55
 */
/**
 * 地址文件下载
 * @param url
 * @param name 文件名
 * @param extname 文件扩展名
 */
function download(url, name, extname) {
  const link = document.createElement('a');
  link.href = url;
  link.download = `${name}.${extname}`;
  link.click();
}

/**
 * blob文件下载
 * @param arrayBuffer 二进制流数据
 * @param name 文件名
 * @param extname 文件扩展名
 */
function downloadByBlob(arrayBuffer, name, extname) {
  const blob = new Blob([arrayBuffer]);
  const url = URL.createObjectURL(blob);
  download(url, name, extname);
  URL.revokeObjectURL(url);
}

/**
 * 文件分片上传
 * @param file 文件
 * @param chunkSize 每个切片的大小（mb）
 */
function splitChunks(file, chunkSize) {}